package com.firefly.service.repository.cms;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.firefly.dao.dao.cms.po.AdPo;
import com.firefly.dao.dao.cms.service.AdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description: 广告
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2022/12/18
 **/
@Repository
public class AdRepository {
    private final AdService adService;
    @Autowired
    public AdRepository(AdService adService){
        this.adService = adService;
    }

    public Boolean create(AdPo entity){
        return adService.save(entity);
    }

    public Boolean update(AdPo entity){
        return adService.updateById(entity);
    }

    public Boolean updateSortById(int id,int sort){
        UpdateWrapper<AdPo> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id",id).set("sort",sort);
        return adService.update(updateWrapper);
    }

    public Boolean updateDelFlagById(List<Integer> ids){
        UpdateWrapper<AdPo> updateWrapper = new UpdateWrapper<>();
        updateWrapper.in("id",ids).set("del_flag",1);
        return adService.update(updateWrapper);
    }
}
